#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int bin_search(int arr[],int key,int sz)
{
	int left = 0;
	int c=key;
	int d=sz;
	int right = d-1;
	int mid = (right-left) / 2; int a = 1;
		while (left<=right)
		{
			if (arr[mid] > c)
			{
				right = mid - 1;
				return;
				
			}
			if (arr[mid] < c)
			{
				left = mid + 1;
			
				return;
			}
			else
			{
				a = 0;
				break;
				return;
			}
		}
		if (a == 0)
		{
			return mid;
		}
		else
			return -1;
		
 }
int main() {
	int arr[10] = {1,2,3,4,5,6,7,8,9,10 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int c = 5;
int d=bin_search(arr,c,sz);
printf("%d", d);
	return 0;
}